export default {
    list: [],
    add: function (name, fn) {
        const that = this;
        const item = that.list.find(item => item.name === name);
        switch (item != null) {
            case true:
                item.fn = fn;
                break;
            case false:
                that.list.push({
                    name: name,
                    fn: fn
                });
                break
        }
    },
    execute: function (name, data) {
        this.list.forEach(x => {
            if (x.name == name)
                x.fn(data);
        });
    }
}